<!-- 管理员界面 -->
<title>后台管理员</title>

<div class="layui-card layadmin-header">
	<div class="layui-breadcrumb" lay-filter="breadcrumb">
		<a lay-href="">主页</a>
		<a><cite>业务管理</cite></a>
		<a><cite>学生评教</cite></a>
	</div>
</div>

<!-- 顶部查询 -->
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="layadmin-evalutestudent-formlist">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">评教任务</label>
					<div class="layui-input-inline">
						<!-- <option value="">请选择</option> -->
						<script type="text/html" id="demo">
							<select name="taskId" lay-search lay-filter="type—search">
											  
											  {{# layui.each(d.evalutestudentlist, function(index, item){     }}
											  	<option value={{item.id}}>{{item.name}}</option>
											  {{# });  }}
											  
											</select>
					</script>
						<div id="view"></div>
					</div>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-evalutetask-back-change">
						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
					</button>
				</div>
			</div>
		</div>

		<!-- 中部 -->
		<div class="layui-card-body">

			<!-- 表格开始 -->
			<table id="LAY-evalutestudent-back-manage" lay-filter="LAY-evalutestudent-back-manage"></table>

			<script type="text/html" id="table-evalutestudent-admin">
				
				{{#  if(d.status == 0){ }}
				  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>开始评教</a>
				{{#  } else { }}
				  <a class="layui-btn layui-btn-xs" lay-event="show"><i class="layui-icon layui-icon-flag"></i>查看结果</a>
				{{#  } }}
			</script>
		</div>
	</div>
</div>

<script>
	layui.use('evaluteteacherself', layui.factory('evaluteteacherself')).use(['admin', 'evaluteteacherself', 'table', 'layer',
		'laytpl'
	], function() {
		var $ = layui.$,
			setter = layui.setter,
			admin = layui.admin,
			view = layui.view,
			table = layui.table,
			form = layui.form,
			laytpl = layui.laytpl,
			layer = layui.layer;

		var tableIns = form.render(null, 'layadmin-evalutestudent-formlist');

		// 初始化
		var evalutestudentlist = [];
		var addData = {};

		function initt() {
			/**
			 * 请求任务option列表
			 * */
			admin.req({
				type: "post",
				url: setter.api_source + 'evalute/optionlist',
				beforeSend: function(XMLHttpRequest) {
					//ShowLoading();
				},
				success: function(data, textStatus) {
					evalutestudentlist = data.data.options
					addData["evalutestudentlist"] = evalutestudentlist;
					// 放在里面避免异步请求延迟的问题
					var getTpl = demo.innerHTML,
						view = document.getElementById('view');
					laytpl(getTpl).render(addData, function(html) {
						view.innerHTML = html;
					});
					// 渲染表单
					form.render(null, 'layadmin-evalutestudent-formlist');
				},
				complete: function(XMLHttpRequest, textStatus) {
					//HideLoading();
				},
				error: function() {
					//请求出错处理
				}
			});

		}
		initt();

		// 监听评价类型变化 根据评价类型id加载
		form.on('submit(LAY-evalutetask-back-change)', function(data) {
			var field = data.field;
			console.log(field);
			console.log("切换任务");
			table.reload('LAY-evalutestudent-back-manage', {
			  url: setter.api_source + 'evalute/zipinList'
			  ,where: {
				  taskId:field.taskId
			  } //设定异步数据接口的额外参数
			  //,height: 300
			});
			// admin.req({
			// 	type: "post",
			// 	url: setter.api_source + 'evalute/list',
			// 	data: field,
			// 	beforeSend: function(XMLHttpRequest) {
			// 		//ShowLoading();
			// 	},
			// 	success: function(data, textStatus) {
			// 		// 渲染 刷新数据
			// 		// insTb.refresh(data.data.rows)
			// 		// tableIns.reload({
			// 		// 	url: setter.api_source + 'evalute/list'
			// 		// });
					
			// 	},
			// 	complete: function(XMLHttpRequest, textStatus) {
			// 		//HideLoading();
			// 	},
			// 	error: function() {
			// 		//请求出错处理
			// 	}
			// });
		});



		$('.layui-btn.layuiadmin-btn-admin').on('click', function() {
			var type = $(this).data('type');
			// active[type] ? active[type].call(this) : '';
		});
	});
</script>
